import store from '@/store'
import router from '@/router'

const tagUtil = {
  /**
  * 操作成功后刷新页面 
  * @param {*} optionName   //组件名
  *  //添加成功后返回并关闭标签页，刷新页面
         this.$store
           .dispatch('tag/closeOpendedTag', this.$options.name)  //this.$options.name当前要关闭的标签组件name
           .then(() => {
             XM.rp.byName(
               'eventBranchList',
               {
                 eventBranchId: this.$route.query.eventBranchId,
                 operation: true,
               },
               this.branchName,
             )
             this.$_tagUtil.refresh('eventBranchList')
           })
  */
  refresh(optionName) {
    store.dispatch('tag/delCachedPage', optionName).then(cachedViews => {
      const fullPath = this.$route.fullPath
      this.$nextTick(() => {
        router.replace({
          path: '/redirect' + fullPath,
        })
        store.dispatch('tag/addCachedPage', optionName)
      })
    })
  },
}

export default tagUtil
